﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;

namespace WorkNodeFramework
{
    public class ExecuteCommandManager
    {
        ExecuteCommand[] commands;
        internal event EventHandler ExecuteCommandsCompleted;

        public ExecuteCommandManager(params ExecuteCommand[] commands) {
            this.commands = commands;
        }

        public ExecuteCommand[] ExecuteCommands {
            get {
                return commands;
            }
        }

        internal void OnExecuteCommandsCompleted(EventArgs e) {
            if (ExecuteCommandsCompleted != null)
                ExecuteCommandsCompleted(this, e);
        }
    }

    public interface IExecuteCommand
    {
        ExecuteCommand BuildExecuteCommand();
    }

    public class ExecuteCommand
    {
        string cmdText;
        DbParameter[] parameters;

        public ExecuteCommand(string cmdText, params DbParameter[] parameters)
        {
            this.cmdText = cmdText;
            if(parameters.Length>0)
                this.parameters = parameters;
        }

        public string CmdText
        {
            get {
                return cmdText;
            }
        }

        public DbParameter[] Parameters
        {
            get {
                return parameters;
            }
        }
    }
}
